// ml:run = $bin < input
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>

int const maxn = 407;
int const maxm = maxn * maxn * 2;

struct edge
{
    int x, y;
};

edge edges[maxm];
int head[maxn], end[maxm], next[maxm], id[maxm];
bool del[maxm];
int alloc = 2;
int in[maxn], out[maxn];
int n, m;

void init()
{
    alloc = 2;
    std::memset(head, 0, sizeof(head));
    std::memset(del, 0, sizeof(del));
    std::memset(out, 0, sizeof(out));
    std::memset(in, 0, sizeof(in));
}

void add_edge(int u, int v, int tid)
{
	end[alloc] = v; next[alloc] = head[u]; id[alloc] = tid;
	head[u] = alloc++;

	end[alloc] = u; next[alloc] = head[v]; id[alloc] = tid;
	head[v] = alloc++;
}

std::vector<int> euler_path;

void find_circuit(int u)
{
	// trik part int & p, every time use head[u] and update it to next
	// to ensure no edge to be visited twice
	for (int & p = head[u]; p; p = next[p]) {
		if (del[p]) continue;
		int v = end[p], tid = id[p];
        edges[tid].x = u;
        edges[tid].y = v;
        out[u]++;
        in[v]++;
		del[p] = del[p ^ 1] = true;
		find_circuit(v);
	}
	euler_path.push_back(u);
}

int main()
{
	std::ios::sync_with_stdio(false);
    int T; std::cin >> T;
    while (T--) {
        std::cin >> n >> m;
        init();
        for (int i = 0, x, y; i < m; i++) {
            std::cin >> x >> y;
            edges[i].x = x;
            edges[i].y = y;
            add_edge(x, y, i);
        }

        for (int i = 1; i <= n; i++) {
            if (in[i] + out[i]) continue;
            find_circuit(i);
        }

        int ans = 0;
        for (int i = 1; i <= n; i++)
            if (in[i] == out[i]) ans++;
        std::cout << ans << "\n";
        for (int i = 0; i < m; i++)
            std::cout << edges[i].x << " " << edges[i].y << "\n";
    }
}

